<?php
class InformationModel extends Model{
	// ------------------------------------------------insert----------------------------------------------
	public function add_information($data)
	{
		import('ORG.Net.UploadFile');
        $upload = new UploadFile();// 实例化上传类
        $upload->maxSize  = 3145728 ;// 设置附件上传大小
        $upload->allowExts  = '';// 设置附件上传类型
        $upload->savePath='Public/Uploads/information/';//设置附件上传目录
        if(!$upload->upload()) 
        {// 上传错误提示错误信息
            $this->error($upload->getErrorMsg());
        }else
        {   
            // 上传成功 获取上传文件信息
            $info =  $upload->getUploadFileInfo();
            $data['time_insert'] = time();
            $data['time_update'] = 0;
            $data['time_delete'] = -1;
            $data['information_size'] = round($info[0]['size']/1000000 , 2);
            $data['information_type'] = $info[0]['extension'];
            $data['information_image'] = $info[0]['savepath'].$info[0]['savename'];
			return M('information' , '' , 'DB_MEETING')->add($data);
		}
	}

	public function add_information_channel($data)
	{
		if($data){
            $data['time_insert'] = time();
            $data['time_update'] = 0;
            $data['time_delete'] = -1;
            return M('information_channel' , '' , 'DB_MEETING')->add($data);
        }else{
 			return false;        
        }
	}

	public function update_information($data)
	{
		import('ORG.Net.UploadFile');
        $upload = new UploadFile();// 实例化上传类
        $upload->maxSize  = 3145728 ;// 设置附件上传大小
        $upload->allowExts  = '';// 设置附件上传类型
        $upload->savePath='Public/Uploads/information/';//设置附件上传目录
        if($upload->upload()) {// 上传错误提示错误信息
             // 上传成功 获取上传文件信息
            $info =  $upload->getUploadFileInfo();
            $data['information_size'] = round($info[0]['size']/1000000 , 2);
            $data['information_type'] = $info[0]['extension'];
            $data['information_image'] = $info[0]['savepath'].$info[0]['savename'];
        }
        $data['time_update'] = time();
        return M('information' ,'' ,'DB_MEETING')->where('information_id='.$data['information_id'])->save($data);
	}

	public function to_del_channel($data)
	{
		return M('information_channel','','DB_MEETING')->where('channel_id='.$data['channel_id']) ->setField('time_delete' , time());
	}

	public function to_del($data)
	{
		 return M('information','','DB_MEETING')->where('information_id='.$data['information_id']) ->setField('time_delete' , time());
	}

}

?>